<template>
  <div class="box">
    <div class="redbox">
      <orderhead title="待付款" class="title"></orderhead>
      <div class="time">
        <span>等待买家付款,还有</span
        ><span><van-count-down :time="time" /></span><span>自动关闭</span>
      </div>
      <div class="address">
        <p>
          {{ this.address.name }}<span>{{ this.address.tel }}</span>
        </p>
        <p>{{ this.address.address }}</p>
      </div>
    </div>
    <div class="content">
      <div>
        <ul>
          <li v-for="(item, index) in fukuandata" :key="index">
            <div class="titles">
              <div>{{ item.name }}</div>
              <div class="ck"><div>待付款</div></div>
            </div>
            <div class="contents">
              <div class="leftimg">
                <img :src="item.cShopImgSrc" alt="" />
              </div>
              <div class="righttext">
                <p>{{ item.title }}</p>
                <div class="num">
                  <div class="pricenum">{{ item.ctype }}</div>
                  <div>
                    x<span>{{ item.num }}</span>
                  </div>
                </div>
                <p>
                  ￥<span>{{ item.price * item.num }}</span>
                </p>
              </div>
            </div>
            <!-- <div class="nums">
              <div>
                {{ item.price * item.num }}
              </div>
              <div class="btns">
                <button @click="cancel(index)">取消订单</button>
                <button @click="tobepaid(item)">去付款</button>
              </div>
            </div> -->
          </li>
        </ul>
      </div>
    </div>
    <div class="pricebox">
      <ul>
        <li v-for="(item, index) in pricelist" :key="index">
          <div class="priceall">{{ item.title }}</div>
          <div class="prices"><span>￥</span>{{ item.price }}</div>
        </li>
      </ul>
      <ul class="bordertop">
        <li>
          <div class="priceall">备注:</div>
        </li>
        <li>
          <div class="priceall">实付金额</div>
          <div class="prices prices-c">
            <span>￥</span>{{price }}
          </div>
        </li>
      </ul>
    </div>
    <div class="information">
      <ul>
        <li v-for="(item, index) in btmlist" :key="index">
          <div class="priceall">
            {{ item.title }}
            <span>{{ item.num }}</span>
          </div>
          <div class="prices">{{ item.text }}</div>
        </li>
      </ul>
      <div class="nowitme">
        当前时间 <span>{{ systemTime }}</span>
      </div>
    </div>
    <div class="paid">
      <button class="cancel">取消订单</button
      ><button @click="fukuanFn()" class="gopaid">付款</button>
    </div>
  </div>
</template>

<script>
import orderhead from "@/pages/Shop/order/orderhead";
import pulicslot from "../pulicslot";
import { mapState ,mapGetters} from "vuex";
import { Dialog } from 'vant';
export default {
  computed: {
    ...mapGetters(["sunprice"]),
    ...mapState(["fukuandata"]),

  },
  data() {
    return {
      time: 1 * 60 * 60 * 1000,
      address: {},
      systemTime: "",
      pricelist: [
        // {
        //   title: "商品总额",
        //   price: 0,
        // },
        {
          title: "运费总额",
          price: "0",
        },
        // {
        //   title: "订单总额",
        //   price: 0,
        // },
        {
          title: "树叶抵扣",
          price: "0",
        },
        {
          title: "优惠总额",
          price: "0",
        },
      ],
      btmlist: [
        {
          title: "订单编号:",
          num: 2104061933841970,
          text: "复制",
        },
        {
          title: "支付方式",
          text: "微信",
        },
      ],
      price:0
    };
  },
  components: {
    orderhead,
  },
  mounted() {
    if(!localStorage.getItem('shouhuoaddress')){
      return
    }else{
      this.address=JSON.parse(localStorage.getItem("shouhuoaddress"));
      console.log(this.address);
    }
    
    // console.log(this.address);
    this.addDate();
    console.log(this.$store.state.fukuandata);
    this.$store.state.fukuandata.forEach(item=>{
      this.price=item.price*item.num
    })
    console.log(this.price);
  },
  methods: {
    addDate() {
      let nowDate = new Date();
      let date = {
        year: nowDate.getFullYear(),
        month: nowDate.getMonth() + 1,
        date: nowDate.getDate(),
        hh: nowDate.getHours(),
        m:
          nowDate.getMinutes() < 10
            ? "0" + new Date().getMinutes()
            : new Date().getMinutes(),
        ss:
          nowDate.getSeconds() < 10
            ? "0" + new Date().getSeconds()
            : new Date().getSeconds(),
      };
      this.systemTime =
        date.year +
        "-" +
        date.month +
        "-" +
        date.date +
        "  " +
        date.hh +
        ":" +
        date.m +
        ":" +
        date.ss;
      console.log(this.systemTime);
    },
    //付款按钮
    fukuanFn(index) {
      Dialog.alert({
        message: "付款成功",
      }).then(() => {
        // on close
        let objarr=JSON.parse(localStorage.getItem('shangpindata'));
        console.log(objarr);
        // for (let i = 0; i < objarr.length; i++) {
        //   objarr[this.$store.state.fukuanindex].paystatus="代发货"
          
        // }
        objarr.forEach(item=>{
          if(item.ctype==this.$store.state.fukuanindex.ctype){
item.paystatus="代发货"
          }
          
        })
        localStorage.setItem('shangpindata',JSON.stringify(objarr) )
        this.$router.push("/myorder")
        
      });
    },
  },
};
</script>
    
<style scoped lang="less">
.box {
  width: 100vw;
  height: 100vh;
  background-color: #f2f2f2;
  .redbox {
    background-color: #fd2c49;
    height: 300px;
    border-radius: 13%;
    font-size: 25px;
    position: relative;
    .title {
      background-color: #fd2c49;
      color: #fff;
    }
    .time {
      position: absolute;
      top: 45%;
      font-size: 33px;
      width: 100%;
      color: #fff;
      text-align: left;
      padding-left: 80px;
      span {
        display: inline-block;
      }
      .van-count-down {
        color: #fff;
        font-size: 33px;
      }
    }
    .address {
      background-color: #fff;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      bottom: -20%;
      width: 88%;
      height: 160px;
      border-radius: 20px;
      text-align: left;
      font-size: 30px;
      padding: 30px 20px;
      line-height: 50px;
      box-shadow: 0 5px 5px rgba(100, 100, 100, 0.2);
      span {
        padding-left: 40px;
      }
    }
  }
  .content {
    margin: 80px 45px 20px 45px;
    border-radius: 30px;
    li {
      padding: 10px 40px 30px 40px;
      font-size: 33px;
      margin-top: 20px;
      background-color: #fff;
      border-radius: 10px;
      .titles {
        display: flex;
        justify-content: space-between;
        .ck {
          font-size: 25px;
          color: red;
        }
      }
      .contents {
        display: flex;
        text-align: left;
        img {
          width: 180px;
        }
        .righttext {
          width: 70%;
          margin-left: 20px;
          line-height: 60px;
          font-size: 27px;
          .num {
            display: flex;
            justify-content: space-between;
            .pricenum {
              background-color: #f2f2f2;
            }
            :nth-child(1) {
              border-radius: 30px;
              width: 300px;
              height: 40px;
              line-height: 40px;
              font-size: 25px;
              text-align: center;
              margin-top: 10px;
            }
            :nth-child(2) {
              color: #d9d9d9;
            }
          }
          :nth-child(3) {
            color: red;
          }
        }
      }
      .nums {
        display: flex;
        justify-content: space-between;
        width: 100%;
        font-size: 25px;
        .btns {
          width: 56%;
          button {
            width: 140px;
            border: 4px solid #d0d0d0;
            border-radius: 30px;
            margin-left: 15px;
            background-color: #fff;
          }
          :nth-child(1) {
            color: #d0d0d0;
            border-color: #d0d0d0;
          }
          :nth-child(2) {
            color: red;
            border-color: red;
          }
        }
      }
    }
  }
  .pricebox {
    margin: 20px 45px;
    background-color: #fff;
    height: 370px;
    width: 88%;
    border-radius: 10px;
    ul {
      margin: 5px 15px;
    }
    .bordertop {
      margin-top: 20px;
      padding-top: 10px;
      border-top: 1px solid #d6d6d6;
    }
    li {
      display: flex;
      justify-content: space-between;
      font-size: 28px;
      line-height: 45px;
      .priceall {
        color: #b9b9b9;
      }
      .prices-c {
        color: red;
      }
    }
  }
  .information {
    margin: 20px 45px;
    background-color: #fff;
    height: 160px;
    width: 88%;
    border-radius: 10px;
    ul {
      margin: 5px 15px;
    }
    li {
      display: flex;
      justify-content: space-between;
      font-size: 28px;
      line-height: 55px;
      .priceall {
        color: #b9b9b9;
      }
    }
    .nowitme {
      font-size: 28px;
      display: flex;
      justify-content: space-between;
      padding: 0 15px;
      color: #b9b9b9;
      span {
        color: #000;
      }
    }
  }
  .paid {
    width: 88%;
    margin: 20px 45px;
    background-color: pink;
    display: flex;
    justify-content: space-between;
    border-radius: 10px;
    button {
      width: 50%;
      font-size: 25px;
      line-height: 50px;
      color: #fff;
    }
    .cancel {
      background-color: #ccc;
      border-top-left-radius: 10px;
      border-bottom-left-radius: 10px;
    }
    .gopaid {
      background-color: #fd2c49;
      border-top-right-radius: 10px;
      border-bottom-right-radius: 10px;
    }
  }
}
</style>